/*
 * Copyright 2009-2010 Belmont Software Services
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.belmont.backup;

import org.json.*;

public class FileRequest extends JSONObject {
    public FileRequest(String name, String digest, long length, long offset) {
	super();
	try {
	    put("name", name);
	    put("digest", digest);
	    put("size", length);
	    put("offset", offset);
	} catch (JSONException ex) {
	    ex.printStackTrace();
	}
    }

    public static String getName(JSONObject obj) {
	return obj.optString("name");
    }

    public String getName() {
	return optString("name");
    }

    public static String getDigest(JSONObject obj) {
	return obj.optString("digest");
    }

    public String getDigest() {
	return optString("digest");
    }

    public static long getLength(JSONObject obj) {
	return obj.optLong("size");
    }

    public long getLength() {
	return optLong("size");
    }

    public static long getOffset(JSONObject obj) {
	return obj.optLong("offset");
    }

    public long getOffset() {
	return optLong("offset");
    }
}
